<include file="nav:headr"/>
<div class="container">
    <div class="row">
        <div style="height: 30px"></div>
        <div class="col-md-2">
            <include file="tools:tools_sider"/>
        </div>
        <div class="col-md-10">
            <div class="page-header">
                <h4>{$page_title}</h4>
            </div>
            <div class="btn-group" role="group" aria-label="...">
                <a  href="{:U('Navs/index')}" type="button" class="btn btn-default">بارلىق تىزىملىكلەر</a>
                <a href="{:U('Navs/add')}" type="button" class="btn btn-default">يېڭىدىن قوشۇش</a>
            </div>
            <br><br>
            <table class="table table-bordered">
                <thead>
                <tr class="active">
                    <td width="30">ID</td>
                    <td>تەرتىب </td>
                    <td> تىزىملىك نامى</td>
                    <td width="55">ھالىتى</td>
                    <td>مەشغۇلات</td>
                </tr>
                </thead>
                <tbody>
                <foreach name="navs" item="n">
                    <tr>
                        <td>{$n['id']}</td>
                        <td>
                          <input onchange="navsSort(this,{$n['id']})" class="form-control" value="{$n['sort']}">
                        </td>
                        <td>{$n['name']}</td>
                        <td>
                            <if condition="$n['status']">
                                <span class="label label-success">ئوچۇق</span>
                                <else/>
                                <span class="label label-danger">تاقاق</span>
                            </if>
                        </td>
                        <td>
                            <a href="{:U('Navs/edit',array('id'=>$n['id']))}" class="btn btn-success btn-sm">تەھرىرلەش</a>
                            <a  href="javascript:deleteNavs({$n['id']})" class="btn btn-danger btn-sm">ئۆچۈرۈش</a>

                        </td>
                    </tr>
                </foreach>
                </tbody>
            </table>
        </div>
    </div>
</div>
<script type="text/javascript">
    function navsSort(obj,id) {
        var sort=$(obj).val();
        $.ajax({
            'url':"{:U('Navs/navsSort')}",
            'type':'POST',
            'dataType':'json',
            'data':{'id':id,'sort':sort},
            success:function (phpRetrnData) {
                if(phpRetrnData.status){
                    layer.msg(phpRetrnData.message,{'icon':6},function () {
                        window.location=location;
                    })
                }else {
                    layer.msg(phpRetrnData.message,{'icon':5});
                }
            }
        })
    }
    //删除提示框
    function deleteNavs(id) {
        //询问框
        layer.confirm('راستىنلا ئۆچۈرەمسىز？', {
            btn: ['ھەئە','ياق'] //按钮
        }, function(){
            $.ajax({
                'url':"{:U('Navs/deleteNavs')}",
                'type':'POST',
                'dataType':'json',
                'data':{'id':id},
                success:function (phpRetrnData) {
                    if(phpRetrnData.status){
                        layer.msg(phpRetrnData.message,{'icon':6},function () {
                            window.location=location;
                        })
                    }else {
                        layer.msg(phpRetrnData.message,{'icon':5});
                    }
                }
            })
        });
    }
</script>

<include file="nav:footer" />